home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / Transport Independent Speech / SpokenSerialApp / Listening.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-16  |  1.5 KB  |  54 lines  |  [TEXT/CWIE]

  1. #ifndef __LISTENING__
  2. #include "Listening.h"
  3. #endif
  4.  
  5. OSErr        InitSpeechRecognition    (SpeechInfoPtr theSpeechInfo)
  6. {
  7.     OSErr        theErr        = noErr;
  8.  
  9.     /* Make sure SpeechRecognition Toolbox is available */
  10.     theErr = Gestalt (gestaltSpeechRecognitionVersion, &theSpeechInfo->attributes);
  11.     /* Version number must be at least 1.5 to support Speech Recognition Toolbox API used here. */
  12.     if (theErr == noErr) {
  13.         if (theSpeechInfo->attributes < 0x00000150) {
  14.             theErr = kNotEnoughSpeechVersion;
  15.         }
  16.     }
  17.  
  18.     return theErr;
  19. }
  20.  
  21. OSErr        OpenSpeechRecognition    (SpeechInfoPtr theSpeechInfo)
  22. {
  23.     OSErr        theErr        = noErr;
  24.  
  25.     theErr = SROpenRecognitionSystem (&theSpeechInfo->recogSystem, kSRDefaultRecognitionSystemID);
  26.  
  27.     return theErr;
  28. }
  29.  
  30. OSErr        ConfigureRecognition    (SpeechInfoPtr theSpeechInfo)
  31. {
  32.     OSErr        theErr            = noErr;
  33.     short        feedbackModes    = kSRHasFeedbackHasListenModes;
  34.  
  35.     /* We use the default feedback and listening modes */
  36.     theErr = SRSetProperty (theSpeechInfo->recogSystem, kSRFeedbackAndListeningModes, &feedbackModes, sizeof (feedbackModes));
  37.  
  38.     return theErr;
  39. }
  40.  
  41. OSErr        GetNewRecognizer        (SpeechInfoPtr theSpeechInfo)
  42. {
  43.     OSErr        theErr            = noErr;
  44.     Boolean        forground        = false;        //We want to recognize even if in the background
  45.  
  46.     /* Create a recognizer with default speech source -- e.g. the desktop microphone */
  47.     theErr = SRNewRecognizer (theSpeechInfo->recogSystem, &theSpeechInfo->theRecognizer, kSRDefaultSpeechSource);
  48.     if (theErr == noErr) {
  49.         theErr = SRSetProperty (theSpeechInfo->theRecognizer, kSRForegroundOnly, &forground, sizeof (forground));
  50.     }
  51.  
  52.     return theErr;
  53. }
  54.